package com.wjjun.data.respository

import com.wjjun.base.data.model.PageBean
import com.wjjun.base.data.repository.BaseRepository
import com.wjjun.data.bean.ArticleBean
import com.wjjun.data.bean.BannerBean
import com.wjjun.data.datasource.TestNetDataSource
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import javax.inject.Inject

/**
 *
 * author : wangjunjun
 * date   : 2022/7/1
 * desc   :
 */
class TestRepository @Inject constructor(
    private val testNetDataSource: TestNetDataSource,
    defaultDispatcher: CoroutineDispatcher = Dispatchers.IO
) : BaseRepository(defaultDispatcher) {

    suspend fun getIndexList(page: Int): PageBean<ArticleBean> {
        return withContext(defaultDispatcher) {
            testNetDataSource.getIndexList(page)
        }
    }

    suspend fun getBanner(): List<BannerBean> {
        return withContext(defaultDispatcher) {
            testNetDataSource.getBanner()
        }
    }

}